<?php

namespace App\Http\Controllers\Api;

use App\apitransifer\ArticleTransformer;
use Illuminate\Http\Request;
use Modules\Shop\Entities\Article;

class ArticleController extends Controller
{
    public function articles(){
    	$cid=\request ()->query('cid',0);
    	if($cid){
    		return $this->response->collection (Article::where('pid',$cid)->get(),new ArticleTransformer());
		}else{
			return $this->response->collection (Article::where('iscommend',1)->get(),new ArticleTransformer());
		}
	}
	public function article($id){
    	return $this->response->item(Article::find($id),new ArticleTransformer());
	}
}
